package org.example.zsbback.controller;

import org.example.zsbback.service.BookService;
import org.example.zsbback.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(origins = "http://localhost:5500")
@RestController
public class BookController {
    @Autowired
    private BookService bookService;
    @GetMapping("/books")
    public R getBooks(@RequestParam(required = false,defaultValue = "1")int page,
                      @RequestParam(required = false,defaultValue = "2")int limit,
                      @RequestParam(required = false,defaultValue = "") String name) {
//        return R.ok(bookService.findAllBooks(page,limit));
        return R.ok(bookService.findAllBooks(page,limit,name));
    }
//    public R getBooks(int page, int limit,String name) {
//        return R.ok(bookService.findAllBooks(page,limit,name));
//    }

}
